import { createClient } from "~/lib/supabase/client";

import { resolveServiceURL } from "./resolve-service-url";

export async function queryTalents(threadId: string) {
  try {
    const supabase = createClient();
    const {
      data: { session },
    } = await supabase.auth.getSession();
    const res = await fetch(
      resolveServiceURL(`talents?thread_id=${threadId}`),
      {
        method: "GET",
        headers: {
          Authorization: `Bearer ${session?.access_token}`,
        },
      },
    );
    return await res.json();
  } catch {
    return [];
  }
}
